package 判断一个矩阵是否是一个x矩阵;

/**
 * @Program:IntelliJ IDEA
 * @description:
 * @author:香蕉你个啵娜娜 l.h-p@qq.com
 * @create:2023-01-31 11:11
 **/

public class Solution {
    public boolean checkXMatrix(int[][] grid){
        int n = grid.length;
        for (int i = 0; i < n; ++i){
            for (int j = 0; j < n; ++j){
                if (i==j || (i+j) == (n-1)){
                    if (grid[i][j] == 0){
                        return false;
                    }
                } else if (grid[i][j] != 0){
                    return false;
                }
            }
        }
        return true;
    }

}
